#!/bin/sh

if grep -q ^jabber /etc/passwd; then
    echo There already is a jabber user on the system.
else
    echo -n "No jabber user found, creating jabber user ... "
    cat >>/etc/passwd <<EOF
jabber:x:110:500:Jabber:%OPTWARE_TARGET_PREFIX%/var/run/jabberd:%OPTWARE_TARGET_PREFIX%/bin/false
EOF
    cp /etc/passwd /share/hdd/conf/
    echo ok
fi

mkdir -p %OPTWARE_TARGET_PREFIX%/var/lib/jabber
chown -R jabber:root %OPTWARE_TARGET_PREFIX%/var/lib/jabber %OPTWARE_TARGET_PREFIX%/var/log/jabberd %OPTWARE_TARGET_PREFIX%/var/run/jabberd

%OPTWARE_TARGET_PREFIX%/etc/init.d/S80jabber restart
